home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb.new / gdb-3.98 / gdb / gdb.info-1 < prev    next >
Encoding:
Text File  |  1991-08-01  |  47.4 KB  |  1,357 lines

  1. Info file gdb.info, produced by Makeinfo, -*- Text -*- from input
  2. file gdb-all.texinfo.
  3.  
  4.    This file documents the GNU debugger GDB.
  5.  
  6.    Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of
  9. this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this
  15. manual under the conditions for verbatim copying, provided also that
  16. the section entitled "GNU General Public License" is included
  17. exactly as in the original, and provided that the entire resulting
  18. derived work is distributed under the terms of a permission notice
  19. identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for
  23. modified versions, except that the section entitled "GNU General
  24. Public License" may be included in a translation approved by the
  25. Free Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gdb.info,  Node: Top,  Next: Summary,  Prev: (dir),  Up: (dir)
  29.  
  30.    This file describes version 4.0 of GDB, the GNU symbolic debugger.
  31.  
  32. * Menu:
  33.  
  34. * Summary::            Summary of GDB
  35. * New Features::        New Features in GDB version 4.0
  36. * Sample Session::        A Sample GDB Session
  37. * Invocation::            Getting In and Out of GDB
  38. * Commands::            
  39. * Running::            Running Programs Under GDB
  40. * Stopping::            Stopping and Continuing
  41. * Stack::            Examining the Stack
  42. * Source::            Examining Source Files
  43. * Data::            Examining Data
  44. * Symbols::            Examining the Symbol Table
  45. * Altering::            Altering Execution
  46. * GDB Files::        
  47. * Targets::            Specifying a Debugging Target 
  48. * Controlling GDB::        Controlling GDB
  49. * Sequences::            Canned Sequences of Commands
  50. * Emacs::            Using GDB under GNU Emacs
  51. * GDB Bugs::            Reporting Bugs in GDB
  52. * Renamed Commands::        
  53. * Installing GDB::        Installing GDB
  54. * Copying::            GNU GENERAL PUBLIC LICENSE
  55. * Index::            Index
  56.  -- The Detailed Node Listing --
  57.  
  58. Summary of GDB
  59.  
  60. * Free Software::        Free Software
  61. * Contributors::        Contributors to GDB
  62.  
  63. Getting In and Out of GDB
  64.  
  65. * Starting GDB::        Starting GDB
  66. * Leaving GDB::            Leaving GDB
  67. * Shell Commands::        Shell Commands
  68.  
  69. Starting GDB
  70.  
  71. * File Options::        Choosing Files
  72. * Mode Options::        Choosing Modes
  73.  
  74. GDB Commands
  75.  
  76. * Command Syntax::        Command Syntax
  77. * Help::            Getting Help
  78.  
  79. Running Programs Under GDB
  80.  
  81. * Compilation::            Compiling for Debugging
  82. * Starting::            Starting your Program
  83. * Arguments::            Your Program's Arguments
  84. * Environment::            Your Program's Environment
  85. * Working Directory::        Your Program's Working Directory
  86. * Input/Output::        Your Program's Input and Output
  87. * Attach::            Debugging an Already-Running Process
  88. * Kill Process::        Killing the Child Process
  89.  
  90. Stopping and Continuing
  91.  
  92. * Breakpoints::            Breakpoints, Watchpoints, and Exceptions
  93. * Continuing and Stepping::    Resuming Execution
  94. * Signals::            Signals
  95.  
  96. Breakpoints, Watchpoints, and Exceptions
  97.  
  98. * Set Breaks::            Setting Breakpoints
  99. * Set Watchpoints::        Setting Watchpoints
  100. * Exception Handling::        Breakpoints and Exceptions
  101. * Delete Breaks::        Deleting Breakpoints
  102. * Disabling::            Disabling Breakpoints
  103. * Conditions::            Break Conditions
  104. * Break Commands::        Breakpoint Command Lists
  105. * Breakpoint Menus::        Breakpoint Menus
  106. * Error in Breakpoints::    
  107.  
  108. Examining the Stack
  109.  
  110. * Frames::            Stack Frames
  111. * Backtrace::            Backtraces
  112. * Selection::            Selecting a Frame
  113. * Frame Info::            Information on a Frame
  114.  
  115. Examining Source Files
  116.  
  117. * List::            Printing Source Lines
  118. * Search::            Searching Source Files
  119. * Source Path::            Specifying Source Directories
  120. * Machine Code::        Source and Machine Code
  121.  
  122. Examining Data
  123.  
  124. * Expressions::            Expressions
  125. * Variables::            Program Variables
  126. * Arrays::            Artificial Arrays
  127. * Output formats::        Output formats
  128. * Memory::            Examining Memory
  129. * Auto Display::        Automatic Display
  130. * Print Settings::        Print Settings
  131. * Value History::        Value History
  132. * Convenience Vars::        Convenience Variables
  133. * Registers::            Registers
  134. * Floating Point Hardware::    Floating Point Hardware
  135.  
  136. Altering Execution
  137.  
  138. * Assignment::            Assignment to Variables
  139. * Jumping::            Continuing at a Different Address
  140. * Signaling::            Giving the Program a Signal
  141. * Returning::            Returning from a Function
  142. * Calling::            Calling your Program's Functions
  143.  
  144. GDB's Files
  145.  
  146. * Files::            Commands to Specify Files
  147. * Symbol Errors::        Errors Reading Symbol Files
  148.  
  149. Specifying a Debugging Target 
  150.  
  151. * Active Targets::        Active Targets
  152. * Target Commands::        Commands for Managing Targets
  153. * Remote::            Remote Debugging
  154.  
  155. Remote Debugging
  156.  
  157. * i960-Nindy Remote::        
  158. * EB29K Remote::        
  159. * VxWorks Remote::        
  160.  
  161. GDB with a Remote i960 (Nindy)
  162.  
  163. * Nindy Startup::        Startup with Nindy
  164. * Nindy Options::        Options for Nindy
  165. * Nindy reset::            Nindy Reset Command
  166.  
  167. GDB with a Remote EB29K
  168.  
  169. * Comms (EB29K)::        Communications Setup
  170. * gdb-EB29K::            EB29K cross-debugging
  171. * Remote Log::            Remote Log
  172.  
  173. GDB and VxWorks
  174.  
  175. * VxWorks connection::        Connecting to VxWorks
  176. * VxWorks download::        VxWorks Download
  177. * VxWorks attach::        Running Tasks
  178.  
  179. Controlling GDB
  180.  
  181. * Prompt::            Prompt
  182. * Editing::            Command Editing
  183. * History::            Command History
  184. * Screen Size::            Screen Size
  185. * Numbers::            Numbers
  186. * Messages/Warnings::        Optional Warnings and Messages
  187.  
  188. Canned Sequences of Commands
  189.  
  190. * Define::            User-Defined Commands
  191. * Command Files::        Command Files
  192. * Output::            Commands for Controlled Output
  193.  
  194. Reporting Bugs in GDB
  195.  
  196. * Bug Criteria::        Have You Found a Bug?
  197. * Bug Reporting::        How to Report Bugs
  198.  
  199. 
  200. File: gdb.info,  Node: Summary,  Next: New Features,  Prev: Top,  Up: Top
  201.  
  202. Summary of GDB
  203. **************
  204.  
  205.    The purpose of a debugger such as GDB is to allow you to see what
  206. is going on "inside" another program while it executes--or what
  207. another program was doing at the moment it crashed.
  208.  
  209.    GDB can do four main kinds of things (plus other things in support
  210. of these) to help you catch bugs in the act:
  211.  
  212.    * Start your program, specifying anything that might affect its
  213.      behavior.
  214.  
  215.    * Make your program stop on specified conditions.
  216.  
  217.    * Examine what has happened, when your program has stopped.
  218.  
  219.    * Change things in your program, so you can experiment with
  220.      correcting the effects of one bug and go on to learn about
  221.      another.
  222.  
  223.    GDB can be used to debug programs written in C and C++.  Pascal
  224. support is being implemented, and Fortran support will be added when
  225. a GNU Fortran compiler is ready.
  226.  
  227. * Menu:
  228.  
  229. * Free Software::        Free Software
  230. * Contributors::        Contributors to GDB
  231.  
  232. 
  233. File: gdb.info,  Node: Free Software,  Next: Contributors,  Prev: Summary,  Up: Summary
  234.  
  235. Free Software
  236. =============
  237.  
  238.    GDB is "free software", protected by the GNU General Public
  239. License (GPL).  The GPL gives you the freedom to copy or adapt a
  240. licensed program--but every person getting a copy also gets with it
  241. the freedom to modify that copy (which means that they must get
  242. access to the source code), and the freedom to distribute further
  243. copies.  Typical software companies use copyrights to limit your
  244. freedoms; the Free Software Foundation uses the GPL to preserve
  245. these freedoms.
  246.  
  247.    Fundamentally, the General Public License is a license which says
  248. that you have these freedoms and that you can't take these freedoms
  249. away from anyone else.
  250.  
  251.    For full details, *note Copying::..
  252.  
  253. 
  254. File: gdb.info,  Node: Contributors,  Prev: Free Software,  Up: Summary
  255.  
  256. Contributors to GDB
  257. ===================
  258.  
  259.    Richard Stallman was the original author of GDB, and of many other
  260. GNU programs.  Many others have contributed to its development. 
  261. This section attempts to credit major contributors.  One of the
  262. virtues of free software is that everyone is free to contribute to
  263. it; with regret, we cannot actually acknowledge everyone here.  The
  264. file `ChangeLog' in the GDB distribution approximates a blow-by-blow
  265. account.
  266.  
  267.    Changes much prior to version 2.0 are lost in the mists of time.
  268.  
  269.      *Plea:* Additions to this section are particularly welcome.  If
  270.      you or your friends (or enemies; let's be evenhanded) have been
  271.      unfairly omitted from this list, we would like to add your names!
  272.  
  273.    So that they may not regard their long labor as thankless, we
  274. particularly thank those who shepherded GDB through major releases:
  275. John Gilmore (release 4.0); Jim Kingdon (releases 3.9, 3.5, 3.4,
  276. 3.3); and Randy Smith (releases 3.2, 3.1, 3.0).  As major maintainer
  277. of GDB for some period, each contributed significantly to the
  278. structure, stability, and capabilities of the entire debugger.
  279.  
  280.    Richard Stallman, assisted at various times by Pete TerMaat, Chris
  281. Hanson, and Richard Mlynarik, handled releases through 2.8.
  282.  
  283.    Michael Tiemann is the author of most of the GNU C++ support in
  284. GDB, with significant additional contributions from Per Bothner. 
  285. James Clark wrote the GNU C++ demangler.  Early work on C++ was by
  286. Peter TerMaat (who also did much general update work leading to
  287. release 3.0).
  288.  
  289.    GDB 4.0 uses the BFD subroutine library to examine multiple
  290. object-file formats; BFD was a joint project of V. Gumby
  291. Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
  292.  
  293.    David Johnson wrote the original COFF support; Pace Willison did
  294. the original support for encapsulated COFF.
  295.  
  296.    Adam de Boor and Bradley Davis contributed the ISI Optimum V
  297. support.  Per Bothner, Noboyuki Hikichi, and Alessandro Forin
  298. contributed MIPS support.  Jean-Daniel Fekete contributed Sun 386i
  299. support.  Chris Hanson improved the HP9000 support.  Noboyuki
  300. Hikichi
  301. and Tomoyuki Hasei contributed Sony/News OS 3 support.  David
  302. Johnson contributed Encore Umax support.  Jyrki Kuoppala contributed
  303. Altos 3068 support.  Keith Packard contributed NS32K support.  Doug
  304. Rabson contributed Acorn Risc Machine support.  Chris Smith
  305. contributed Convex support (and Fortran debugging).  Jonathan Stone
  306. contributed Pyramid support.  Michael Tiemann contributed SPARC
  307. support.  Tim Tucker contributed support for the Gould NP1 and Gould
  308. Powernode.  Pace Willison contributed Intel 386 support.  Jay
  309. Vosburgh contributed Symmetry support.
  310.  
  311.    Rich Schaefer helped with support of SunOS shared libraries.
  312.  
  313.    Jay Fenlason and Roland McGrath ensured that GDB and GAS agree
  314. about several machine instruction sets.
  315.  
  316.    Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
  317. develop remote debugging.  Intel Corporation and Wind River Systems
  318. contributed remote debugging modules for their products.
  319.  
  320.    Brian Fox is the author of the readline libraries providing
  321. command-line editing and command history.
  322.  
  323. 
  324. File: gdb.info,  Node: New Features,  Next: Sample Session,  Prev: Summary,  Up: Top
  325.  
  326. New Features since GDB version 3.5
  327. **********************************
  328.  
  329. *Targets*
  330.      Using the new command `target', you can select at runtime
  331.      whether you are debugging local files, local processes,
  332.      standalone systems over a serial port, realtime systems over a
  333.      TCP/IP connection, etc.  Internally, GDB now uses a function
  334.      vector to mediate access to different targets; if you need to
  335.      add your own support for a remote protocol, this makes it much
  336.      easier.
  337.  
  338. *Watchpoints*
  339.      GDB now sports watchpoints as well as breakpoints.  You can use
  340.      a watchpoint to stop execution whenever the value of an
  341.      expression changes, without having to predict a particular
  342.      place in your program where this may happen.
  343.  
  344. *Object Code Formats*
  345.      GDB uses a new scheme called the Binary File Descriptor (BFD)
  346.      Library to permit it to switch dynamically, without
  347.      reconfiguration or recompilation, between different object-file
  348.      formats.  Formats currently supported are COFF, a.out, and the
  349.      Intel 960 b.out; files may be read as .o's, archive libraries,
  350.      or core dumps.  BFD is available as a subroutine library so
  351.      that other programs may take advantage of it, and the other GNU
  352.      binary utilities are being converted to use it.
  353.  
  354. *Configuration*
  355.      Compile-time configuration (to select a particular architecture
  356.      and operating system) is much easier.  The script `configure'
  357.      now allows you to configure GDB as either a native debugger or
  358.      a cross-debugger.
  359.  
  360. *Interaction*
  361.      The user interface to GDB's control variables has been
  362.      simplified and consolidated in two commands, `set' and `show'. 
  363.     
  364.      Output lines are now broken at readable places, rather than
  365.      overflowing onto the next line.  You can suppress output of
  366.      machine-level addresses, displaying only source language
  367.      information.
  368.  
  369. *Source Language*
  370.      GDB now has limited support for C++ exception handling: GDB can
  371.      break when an exception is raised, before the stack is peeled
  372.      back to the exception handler's context.
  373.  
  374. *Command Rationalization*
  375.      Many GDB commands have been renamed to make them easier to
  376.      remember and use.  In particular, the subcommands of `info' and
  377.      `show'/`set' are grouped to make the former refer to the state
  378.      of your program, and the latter refer to the state of GDB itself.
  379.      *Note Renamed Commands::, for details on what commands were
  380.      renamed.
  381.  
  382. *Ports*
  383.      GDB has been ported to the following new architectures: AT&T
  384.      3b1, Acorn RISC machine, HP300 running HPUX, big- and
  385.      little-endian MIPS machines, Motorola 88k, Sun 386i, and Sun 3
  386.     
  387.      running SunOS 4.  In addition, the following are supported as
  388.      targets only: AMD 29k, Intel 960, and Wind River's VxWorks.
  389.  
  390. *Shared Libraries*
  391.      GDB 4.0 supports SunOS shared libraries.
  392.  
  393. *Work in Progress*
  394.      Kernel debugging for BSD and Mach systems; Tahoe and HPPA
  395.      architecture support.
  396.  
  397. 
  398. File: gdb.info,  Node: Sample Session,  Next: Invocation,  Prev: New Features,  Up: Top
  399.  
  400. A Sample GDB Session
  401. ********************
  402.  
  403.    You can use this manual at your leisure to read all about GDB. 
  404. However, a handful of commands are enough to get started using the
  405. debugger.  This chapter illustrates these commands.
  406.  
  407.    One of the preliminary versions of GNU `m4' (a generic macro
  408. processor) exhibits the following bug: sometimes, when we change its
  409. quote strings from the default, the commands used to capture one
  410. macro's definition in another stop working.  In the following short
  411. `m4' session, we define a macro `foo' which expands to `0000'; we
  412. then
  413. use the `m4' builtin `defn' to define `bar' as the same thing. 
  414. However, when we change the open quote string to `<QUOTE>' and the
  415. close quote string to `<UNQUOTE>', the same procedure fails to
  416. define a new synonym `baz':
  417.  
  418.      $ cd gnu/m4
  419.      $ ./m4
  420.      define(foo,0000)
  421.      
  422.      foo
  423.      0000
  424.      define(bar,defn(`foo'))
  425.      
  426.      bar
  427.      0000
  428.      changequote(<QUOTE>,<UNQUOTE>)
  429.      
  430.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  431.      baz
  432.      C-d
  433.      m4: End of input: 0: fatal error: EOF in string
  434.  
  435. Let's use GDB to try to see what's going on.
  436.  
  437.      $ gdb m4
  438.      Reading symbol data from m4...done.
  439.      (gdb)
  440.  
  441. GDB reads only enough symbol data to know where to find the rest when
  442. needed;
  443. as a result, the first prompt comes up very quickly.  We then tell
  444. GDB to use a narrower display width than usual, so that examples
  445. will fit in this manual.
  446.  
  447.      (gdb) set width 70
  448.  
  449. Let's see how the `m4' builtin `changequote' works.  Having looked at
  450. the source, we know the relevant subroutine is `m4_changequote', so
  451. we set a breakpoint there with GDB's `break' command.
  452.  
  453.      (gdb) break m4_changequote
  454.      Breakpoint 1 at 0x62f4: file builtin.c, line 879.
  455.  
  456. Using the `run' command, we start `m4' running under GDB control; as
  457. long as control does not reach the `m4_changequote' subroutine, the
  458. program runs as usual:
  459.  
  460.      (gdb) run
  461.      Starting program: /work/Editorial/gdb/gnu/m4/m4 
  462.      define(foo,0000)
  463.      
  464.      foo
  465.      0000
  466.  
  467. To trigger the breakpoint, we call `changequote'.  GDB suspends
  468. execution of `m4', displaying information about the context where it
  469. stops.
  470.  
  471.      changequote(<QUOTE>,<UNQUOTE>)
  472.      
  473.      Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) at builtin.c:879
  474.      879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
  475.  
  476. Now we use the command `n' (`next') to advance execution to the next
  477. line of the current function.
  478.  
  479.      (gdb) n
  480.      882         set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1]) : nil,
  481.  
  482. `set_quotes' looks like a promising subroutine.  We can go into it by
  483. using the command `s' (`step') instead of `next'.  `step' goes to
  484. the next line to be executed in *any* subroutine, so it steps into
  485. `set_quotes'.
  486.  
  487.      (gdb) s
  488.      set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  489.          at input.c:530
  490.      530         if (lquote != def_lquote)
  491.  
  492. The summary display showing the subroutine where `m4' is now
  493. suspended (and its arguments) is called a stack frame display.  We
  494. can use the `backtrace' command (which can also be spelled `bt'), to
  495. see where we are in the stack: it displays a stack frame for each
  496. active subroutine.
  497.  
  498.      (gdb) bt
  499.      #0  set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  500.          at input.c:530
  501.      #1  0x6344 in m4_changequote (argc=3, argv=0x33c70) at builtin.c:882
  502.      #2  0x8174 in expand_macro (sym=0x33320) at macro.c:242
  503.      #3  0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
  504.          at macro.c:71
  505.      #4  0x79dc in expand_input () at macro.c:40
  506.      #5  0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
  507.  
  508. Let's step through a few more lines to see what happens.  The first
  509. two times, we can use `s'; the next two times we use `n' to avoid
  510. falling into the `xstrdup' subroutine.
  511.  
  512.      (gdb) s
  513.      0x3b5c  532         if (rquote != def_rquote)
  514.      (gdb) s
  515.      0x3b80  535         lquote = (lq == nil || *lq == '\0') ? def_lquote :\
  516.       xstrdup(lq);
  517.      (gdb) n
  518.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
  519.      (rq);
  520.      (gdb) n
  521.      538         len_lquote = strlen(rquote);
  522.  
  523. The last line displayed looks a little odd; let's examine the
  524. variables `lquote' and `rquote' to see if they are in fact the new
  525. left and right quotes we specified.  We can use the command `p'
  526. (`print') to see their values.
  527.  
  528.      (gdb) p lquote
  529.      $1 = 0x35d40 "<QUOTE>"
  530.      (gdb) p rquote
  531.      $2 = 0x35d50 "<UNQUOTE>"
  532.  
  533. `lquote' and `rquote' are indeed the new left and right quotes. 
  534. Let's look at some context; we can display ten lines of source
  535. surrounding the current line, with the `l' (`list') command.
  536.  
  537.      (gdb) l
  538.      533             xfree(rquote);
  539.      534     
  540.      535         lquote = (lq == nil || *lq == '\0') ? def_lquote : xstrdup\
  541.      (lq);
  542.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\
  543.      (rq);
  544.      537     
  545.      538         len_lquote = strlen(rquote);
  546.      539         len_rquote = strlen(lquote);
  547.      540     }
  548.      541     
  549.      542     void
  550.  
  551. Let's step past the two lines that set `len_lquote' and `len_rquote',
  552. and then examine the values of those variables.
  553.  
  554.      (gdb) n
  555.      539         len_rquote = strlen(lquote);
  556.      (gdb) n
  557.      540     }
  558.      (gdb) p len_lquote
  559.      $3 = 9
  560.      (gdb) p len_rquote
  561.      $4 = 7
  562.  
  563. That certainly looks wrong, assuming `len_lquote' and `len_rquote'
  564. are
  565. meant to be the lengths of `lquote' and `rquote' respectively. 
  566. Let's try setting them to better values.  We can use the `p' command
  567. for this, since it'll print the value of any expression--and that
  568. expression can include subroutine calls and assignments.
  569.  
  570.      (gdb) p len_lquote=strlen(lquote)
  571.      $5 = 7
  572.      (gdb) p len_rquote=strlen(rquote)
  573.      $6 = 9
  574.  
  575. Let's see if that fixes the problem of using the new quotes with the
  576. `m4' built-in `defn'.  We can allow `m4' to continue executing with
  577. the `c' (`continue') command, and then try the example that caused
  578. trouble initially:
  579.  
  580.      (gdb) c
  581.      Continuing.
  582.      
  583.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  584.      
  585.      baz
  586.      0000
  587.  
  588. Success!  The new quotes now work just as well as the default ones. 
  589. The problem seems to have been just the two typos defining the wrong
  590. lengths.  We'll let `m4' exit by giving it an EOF as input.
  591.  
  592.      C-d
  593.      Program exited normally.
  594.  
  595. The message `Program exited normally.' is from GDB; it indicates `m4'
  596. has finished executing.  We can end our GDB session with the GDB
  597. `quit' command.
  598.  
  599.      (gdb) quit
  600.  
  601. 
  602. File: gdb.info,  Node: Invocation,  Next: Commands,  Prev: Sample Session,  Up: Top
  603.  
  604. Getting In and Out of GDB
  605. *************************
  606.  
  607. * Menu:
  608.  
  609. * Starting GDB::        Starting GDB
  610. * Leaving GDB::            Leaving GDB
  611. * Shell Commands::        Shell Commands
  612.  
  613. 
  614. File: gdb.info,  Node: Starting GDB,  Next: Leaving GDB,  Prev: Invocation,  Up: Invocation
  615.  
  616. Starting GDB
  617. ============
  618.  
  619.    GDB is invoked with the shell command `gdb'.  Once started, it
  620. reads commands from the terminal until you tell it to exit.
  621.  
  622.    You can run `gdb' with no arguments or options; but the most usual
  623. way to start GDB is with one argument or two, specifying an
  624. executable program as the argument:
  625.  
  626.      gdb program
  627.  
  628. You can also start with both an executable program and a core file
  629. specified:
  630.  
  631.      gdb program core
  632.  
  633. You can further control how GDB starts up by using command-line
  634. options.  GDB itself can remind you of the options available:
  635.  
  636.      gdb -help
  637.  
  638. will display all available options and briefly describe their use
  639. (`gdb -h' is a shorter equivalent).
  640.  
  641.    All options and command line arguments you give are processed in
  642. sequential order.  The order makes a difference when the `-x' option
  643. is used.
  644.  
  645. * Menu:
  646.  
  647. * File Options::        Choosing Files
  648. * Mode Options::        Choosing Modes
  649.  
  650. 
  651. File: gdb.info,  Node: File Options,  Next: Mode Options,  Prev: Starting GDB,  Up: Starting GDB
  652.  
  653. Choosing Files
  654. --------------
  655.  
  656.    As shown above, any arguments other than options specify an
  657. executable file and core file; that is, the first argument
  658. encountered with no associated option flag is equivalent to a `-se'
  659. option, and the second, if any, is equivalent to a `-c' option. 
  660. Many options have both long and short forms; both are shown here. 
  661. The long forms are also recognized if you truncate them, so long as
  662. enough
  663. of the option is present to be unambiguous.  (If you prefer, you can
  664. flag
  665. option arguments with `+' rather than `-', though we illustrate the
  666. more usual convention.)
  667.  
  668. `-symbols=FILE'
  669. `-s FILE'
  670.      Read symbol table from file FILE.
  671.  
  672. `-exec=FILE'
  673. `-e FILE'
  674.      Use file FILE as the executable file to execute when
  675.      appropriate, and for examining pure data in conjunction with a
  676.      core dump.
  677.  
  678. `-se=FILE'
  679.      Read symbol table from file FILE and use it as the executable
  680.      file.
  681.  
  682. `-core=FILE'
  683. `-c FILE'
  684.      Use file FILE as a core dump to examine.
  685.  
  686. `-command=FILE'
  687. `-x FILE'
  688.      Execute GDB commands from file FILE.  *Note Command Files::.
  689.  
  690. `-directory=DIRECTORY'
  691. `-d DIRECTORY'
  692.      Add DIRECTORY to the path to search for source files.
  693.  
  694. 
  695. File: gdb.info,  Node: Mode Options,  Prev: File Options,  Up: Starting GDB
  696.  
  697. Choosing Modes
  698. --------------
  699.  
  700. `-nx'
  701. `-n'
  702.      Do not execute commands from any `.gdbinit' initialization files.
  703.      Normally, the commands in these files are executed after all
  704.      the command options and arguments have been processed.  *Note
  705.      Command Files::.
  706.  
  707. `-quiet'
  708. `-q'
  709.      "Quiet".  Do not print the introductory and copyright messages. 
  710.      These messages are also suppressed in batch mode, or if an
  711.      executable file name is specified on the GDB command line.
  712.  
  713. `-batch'
  714.      Run in batch mode.  Exit with status `0' after processing all
  715.      the command files specified with `-x' (and `.gdbinit', if not
  716.      inhibited).  Exit with nonzero status if an error occurs in
  717.      executing the GDB commands in the command files.
  718.  
  719.      Batch mode may be useful for running GDB as a filter, for
  720.      example to download and run a program on another computer; in
  721.      order to make this more useful, the message
  722.  
  723.           Program exited normally.
  724.  
  725.      (which is ordinarily issued whenever a program running under GDB
  726.      control terminates) is not issued when running in batch mode.
  727.  
  728. `-cd=DIRECTORY'
  729.      Run GDB using DIRECTORY as its working directory, instead of the
  730.      current directory.
  731.  
  732. `-fullname'
  733. `-f'
  734.      Emacs sets this option when it runs GDB as a subprocess.  It
  735.      tells GDB to output the full file name and line number in a
  736.      standard, recognizable fashion each time a stack frame is
  737.      displayed (which includes each time the program stops).  This
  738.      recognizable format looks like two `\032' characters, followed
  739.      by the file name, line number and character position separated
  740.      by colons, and a newline.  The Emacs-to-GDB interface program
  741.      uses the two `\032' characters as a signal to display the
  742.      source code for the frame.
  743.  
  744. `-b BPS'
  745.      Set the line speed (baud rate or bits per second) of any serial
  746.      interface used by GDB for remote debugging.
  747.  
  748. `-tty=DEVICE'
  749.      Run using DEVICE for your program's standard input and output.
  750.  
  751. 
  752. File: gdb.info,  Node: Leaving GDB,  Next: Shell Commands,  Prev: Starting GDB,  Up: Invocation
  753.  
  754. Leaving GDB
  755. ===========
  756.  
  757. `quit'
  758.      To exit GDB, use the `quit' command (abbreviated `q'), or type
  759.      an end-of-file character (usually `C-d').
  760.  
  761.    An interrupt (often `C-c') will not exit from GDB, but rather will
  762. terminate the action of any GDB command that is in progress and
  763. return to GDB command level.  It is safe to type the interrupt
  764. character at any time because GDB does not allow it to take effect
  765. until a time when it is safe.
  766.  
  767.    If you've been using GDB to control an attached process or device,
  768. you can release it with the `detach' command; *note Attach::..
  769.  
  770. 
  771. File: gdb.info,  Node: Shell Commands,  Prev: Leaving GDB,  Up: Invocation
  772.  
  773. Shell Commands
  774. ==============
  775.  
  776.    If you need to execute occasional shell commands during your
  777. debugging session, there's no need to leave or suspend GDB; you can
  778. just use the `shell' command.
  779.  
  780. `shell COMMAND STRING'
  781.      Directs GDB to invoke an inferior shell to execute COMMAND
  782.      STRING.  If it exists, the environment variable `SHELL' is used
  783.      for the name of the shell to run.  Otherwise GDB uses `/bin/sh'.
  784.  
  785.    The utility `make' is often needed in development environments. 
  786. You don't have to use the `shell' command for this purpose in GDB:
  787.  
  788. `make MAKE-ARGS'
  789.      Causes GDB to execute an inferior `make' program with the
  790.      specified arguments.  This is equivalent to `shell make
  791.      MAKE-ARGS'.
  792.  
  793. 
  794. File: gdb.info,  Node: Commands,  Next: Running,  Prev: Invocation,  Up: Top
  795.  
  796. GDB Commands
  797. ************
  798.  
  799. * Menu:
  800.  
  801. * Command Syntax::        Command Syntax
  802. * Help::            Getting Help
  803.  
  804. 
  805. File: gdb.info,  Node: Command Syntax,  Next: Help,  Prev: Commands,  Up: Commands
  806.  
  807. Command Syntax
  808. ==============
  809.  
  810.    A GDB command is a single line of input.  There is no limit on how
  811. long it can be.  It starts with a command name, which is followed by
  812. arguments
  813. whose meaning depends on the command name.  For example, the command
  814. `step' accepts an argument which is the number of times to step, as
  815. in `step 5'.  You can also use the `step' command with no arguments.
  816. Some command names do not allow any arguments.
  817.  
  818.    GDB command names may always be truncated if that abbreviation is
  819. unambiguous.  Other possible command abbreviations are listed in the
  820. documentation for individual commands.  In some cases, even
  821. ambiguous abbreviations are allowed; for example, `s' is specially
  822. defined as equivalent to `step' even though there are other commands
  823. whose names start with `s'.  You can test abbreviations by using
  824. them as arguments to the `help' command.
  825.  
  826.    A blank line as input to GDB (typing just RET) means to repeat the
  827. previous command. Certain commands (for example, `run') will not
  828. repeat this way; these are commands for which unintentional
  829. repetition might cause trouble and which you are unlikely to want to
  830. repeat.
  831.  
  832.    The `list' and `x' commands, when you repeat them with RET,
  833. construct new arguments rather than repeating exactly as typed. 
  834. This permits easy scanning of source or memory.
  835.  
  836.    A line of input starting with `#' is a comment; it does nothing. 
  837. This is useful mainly in command files (*Note Command Files::).
  838.  
  839. 
  840. File: gdb.info,  Node: Help,  Prev: Command Syntax,  Up: Commands
  841.  
  842. Getting Help
  843. ============
  844.  
  845.    You can always ask GDB itself for information on its commands,
  846. using the command `help'.
  847.  
  848. `help'
  849. `h'
  850.      You can use `help' (abbreviated `h') with no arguments to
  851.      display a short list of named classes of commands:
  852.  
  853.           (gdb) help
  854.           List of classes of commands:
  855.           
  856.           running -- Running the program
  857.           stack -- Examining the stack
  858.           data -- Examining data
  859.           breakpoints -- Making program stop at certain points
  860.           files -- Specifying and examining files
  861.           status -- Status inquiries
  862.           support -- Support facilities
  863.           user-defined -- User-defined commands
  864.           aliases -- Aliases of other commands
  865.           obscure -- Obscure features
  866.           
  867.           Type "help" followed by a class name for a list of commands in that class.
  868.           Type "help" followed by command name for full documentation.
  869.           Command name abbreviations are allowed if unambiguous.
  870.           (gdb)
  871.  
  872. `help CLASS'
  873.      Using one of the general help classes as an argument, you can
  874.      get a list of the individual commands in that class.  For
  875.      example, here is the help display for the class `status':
  876.  
  877.           (gdb) help status
  878.           Status inquiries.
  879.           
  880.           List of commands:
  881.           
  882.           show -- Generic command for showing things set with "set"
  883.           info -- Generic command for printing status
  884.           
  885.           Type "help" followed by command name for full documentation.
  886.           Command name abbreviations are allowed if unambiguous.
  887.           (gdb)
  888.  
  889. `help COMMAND'
  890.      With a command name as `help' argument, GDB will display a short
  891.      paragraph on how to use that command.
  892.  
  893.    In addition to `help', you can use the GDB commands `info' and
  894. `show' to inquire about the state of your program, or the state of
  895. GDB itself.  Each command supports many topics of inquiry; this
  896. manual introduces each of them in the appropriate context.  The
  897. listings under `info' and under `show' in the Index point to all the
  898. sub-commands.
  899.  
  900. `info'
  901.      This command (abbreviated `i') is for describing the state of
  902.      your program; for example, it can list the arguments given to
  903.      your program (`info args'), the registers currently in use
  904.      (`info registers'), or the breakpoints you've set (`info
  905.      breakpoints').  You can get a complete list of the `info'
  906.      sub-commands with `help info'.
  907.  
  908. `show'
  909.      In contrast, `show' is for describing the state of GDB itself. 
  910.      You can change most of the things you can `show', by using the
  911.      related command `set'; for example, you can control what number
  912.      system is used for displays with `set radix', or simply inquire
  913.      which is currently in use with `show radix'.
  914.  
  915.      To display all the settable parameters and their current values,
  916.      you can use `show' with no arguments; you may also use `info
  917.      set'.  Both commands produce the same display.
  918.  
  919.    Here are three miscellaneous `show' subcommands, all of which are
  920. exceptional in lacking corresponding `set' commands:
  921.  
  922. `show version'
  923.      Show what version of GDB is running.  You should include this
  924.      information in GDB bug-reports.  If multiple versions of GDB
  925.      are in use at your site, you may occasionally want to make sure
  926.      what version of GDB you're running; as GDB evolves, new
  927.      commands are introduced, and old ones may wither away.  The
  928.      version number is also announced when you start GDB with no
  929.      arguments.
  930.  
  931. `show copying'
  932.      Display information about permission for copying GDB.
  933.  
  934. `show warranty'
  935.      Display the GNU "NO WARRANTY" statement.
  936.  
  937. 
  938. File: gdb.info,  Node: Running,  Next: Stopping,  Prev: Commands,  Up: Top
  939.  
  940. Running Programs Under GDB
  941. **************************
  942.  
  943. * Menu:
  944.  
  945. * Compilation::            Compiling for Debugging
  946. * Starting::            Starting your Program
  947. * Arguments::            Your Program's Arguments
  948. * Environment::            Your Program's Environment
  949. * Working Directory::        Your Program's Working Directory
  950. * Input/Output::        Your Program's Input and Output
  951. * Attach::            Debugging an Already-Running Process
  952. * Kill Process::        Killing the Child Process
  953.  
  954. 
  955. File: gdb.info,  Node: Compilation,  Next: Starting,  Prev: Running,  Up: Running
  956.  
  957. Compiling for Debugging
  958. =======================
  959.  
  960.    In order to debug a program effectively, you need to generate
  961. debugging information when you compile it.  This debugging
  962. information is stored in the object file; it describes the data type
  963. of each variable or function and the correspondence between source
  964. line numbers and addresses in the executable code.
  965.  
  966.    To request debugging information, specify the `-g' option when you
  967. run the compiler.
  968.  
  969.    Many C compilers are unable to handle the `-g' and `-O' options
  970. together.  Using those compilers, you cannot generate optimized
  971. executables containing debugging information.
  972.  
  973.    The GNU C compiler supports `-g' with or without `-O', making it
  974. possible to debug optimized code.  We recommend that you *always*
  975. use `-g' whenever you compile a program.  You may think the program
  976. is correct, but there's no sense in pushing your luck.
  977.  
  978.    Some things do not work as well with `-g -O' as with just `-g',
  979. particularly on machines with instruction scheduling.  If in doubt,
  980. recompile with `-g' alone, and if this fixes the problem, please
  981. report it as a bug (including a test case!).
  982.  
  983.    Older versions of the GNU C compiler permitted a variant option
  984. `-gg' for debugging information.  GDB no longer supports this
  985. format; if your GNU C compiler has this option, do not use it.
  986.  
  987. 
  988. File: gdb.info,  Node: Starting,  Next: Arguments,  Prev: Compilation,  Up: Running
  989.  
  990. Starting your Program
  991. =====================
  992.  
  993. `run'
  994. `r'
  995.      Use the `run' command to start your program under GDB.  You must
  996.      first specify the program name (except on VxWorks) with an
  997.      argument to GDB (*note Invocation::.), or using the `file' or
  998.      `exec-file' command (*note Files::.).
  999.  
  1000.    On targets that support processes, `run' creates an inferior
  1001. process and makes that process run your program.  On other targets,
  1002. `run' jumps to the start of the program.
  1003.  
  1004.    The execution of a program is affected by certain information it
  1005. receives from its superior.  GDB provides ways to specify this
  1006. information, which you must do before starting the program.  (You
  1007. can change it after starting the program, but such changes will only
  1008. affect the program the next time you start it.)  This information
  1009. may be divided into four categories:
  1010.  
  1011. The arguments.
  1012.      You specify the arguments to give your program as the arguments
  1013.      of the `run' command.  If a shell is available on your target,
  1014.      the shell is used to pass the arguments, so that you may use
  1015.      normal conventions (such as wildcard expansion or variable
  1016.      substitution) in describing the arguments.  In Unix systems,
  1017.      you can control which shell is used with the `SHELL'
  1018.      environment
  1019.      variable. *Note Arguments::.
  1020.  
  1021. The environment.
  1022.      Your program normally inherits its environment from GDB, but you
  1023.      can use the GDB commands `set environment' and `unset
  1024.      environment' to change parts of the environment that will be
  1025.      given to the program.  *Note Environment::.
  1026.  
  1027. The working directory.
  1028.      Your program inherits its working directory from GDB.  You can
  1029.      set GDB's working directory with the `cd' command in GDB. 
  1030.      *Note Working Directory::.
  1031.  
  1032. The standard input and output.
  1033.      Your program normally uses the same device for standard input
  1034.      and standard output as GDB is using.  You can redirect input
  1035.      and output in the `run' command line, or you can use the `tty'
  1036.      command to set a different device for your program.  *Note
  1037.      Input/Output::.
  1038.  
  1039.      *Warning:* While input and output redirection work, you can't
  1040.      use pipes to pass the output of the program you're debugging to
  1041.      another program; if you attempt this, GDB is likely to wind up
  1042.      debugging the wrong program.
  1043.  
  1044.    When you issue the `run' command, your program begins to execute
  1045. immediately.  *Note Stopping::, for discussion of how to arrange for
  1046. your program to stop.  Once your program has been started by the
  1047. `run' command (and then stopped), you may evaluate expressions that
  1048. involve calls to functions in the inferior, using the `print' or
  1049. `call' commands.  *Note Data::.
  1050.  
  1051.    If the modification time of your symbol file has changed since the
  1052. last time GDB read its symbols, GDB will discard its symbol table
  1053. and re-read it.  In this process, it tries to retain your current
  1054. breakpoints.
  1055.  
  1056. 
  1057. File: gdb.info,  Node: Arguments,  Next: Environment,  Prev: Starting,  Up: Running
  1058.  
  1059. Your Program's Arguments
  1060. ========================
  1061.  
  1062.    The arguments to your program can be specified by the arguments of
  1063. the `run' command.  They are passed to a shell, which expands
  1064. wildcard characters and performs redirection of I/O, and thence to
  1065. the program.  GDB uses the shell indicated by your environment
  1066. variable
  1067. `SHELL' if it exists; otherwise, GDB uses `/bin/sh'.
  1068.  
  1069.    `run' with no arguments uses the same arguments used by the
  1070. previous `run', or those set by the `set args' command.
  1071.  
  1072. `set args'
  1073.      Specify the arguments to be used the next time your program is
  1074.      run.  If `set args' has no arguments, `run' will execute your
  1075.      program with no arguments.  Once you have run your program with
  1076.      arguments,  using `set args' before the next `run' is the only
  1077.      way to run it again without arguments.
  1078.  
  1079. `show args'
  1080.      Show the arguments to give your program when it is started.
  1081.  
  1082. 
  1083. File: gdb.info,  Node: Environment,  Next: Working Directory,  Prev: Arguments,  Up: Running
  1084.  
  1085. Your Program's Environment
  1086. ==========================
  1087.  
  1088.    The "environment" consists of a set of environment variables and
  1089. their values.  Environment variables conventionally record such
  1090. things as your user name, your home directory, your terminal type,
  1091. and your search path for programs to run.  Usually you set up
  1092. environment variables with the shell and they are inherited by all
  1093. the other programs you run.  When debugging, it can be useful to try
  1094. running the program with a modified environment without having to
  1095. start GDB over again.
  1096.  
  1097. `path DIRECTORY'
  1098.      Add DIRECTORY to the front of the `PATH' environment variable
  1099.      (the search path for executables), for both GDB and your program.
  1100.      You may specify several directory names, separated by `:' or
  1101.      whitespace.  If DIRECTORY is already in the path, it is moved
  1102.      to the front, so it will be searched sooner.
  1103.  
  1104.      You can use the string `$cwd' to refer to whatever is the
  1105.      current working directory at the time GDB searches the path. 
  1106.      If you use `.' instead, it refers to the directory where you
  1107.      executed the `path' command.  GDB fills in the current path
  1108.      where needed in the DIRECTORY argument, before adding it to the
  1109.      search path.
  1110.  
  1111. `show paths'
  1112.      Display the list of search paths for executables (the `PATH'
  1113.      environment variable).
  1114.  
  1115. `show environment [VARNAME]'
  1116.      Print the value of environment variable VARNAME to be given to
  1117.      your program when it starts.  If you don't supply VARNAME, 
  1118.      print the names and values of all environment variables to be
  1119.      given to your program.  You can abbreviate `environment' as
  1120.      `env'.
  1121.  
  1122. `set environment VARNAME [=] VALUE'
  1123.      Sets environment variable VARNAME to VALUE.  The value changes
  1124.      for your program only, not for GDB itself.  VALUE may be any
  1125.      string; the values of environment variables are just strings,
  1126.      and any interpretation is supplied by your program itself.  The
  1127.     
  1128.      VALUE parameter is optional; if it is eliminated, the variable
  1129.      is set to a null value.
  1130.  
  1131.      For example, this command:
  1132.  
  1133.           set env USER = foo
  1134.  
  1135.      tells a Unix program, when subsequently run, that its user is
  1136.      named `foo'.  (The spaces around `=' are used for clarity here;
  1137.      they are not actually required.)
  1138.  
  1139. `unset environment VARNAME'
  1140.      Remove variable VARNAME from the environment to be passed to
  1141.      your program.  This is different from `set env VARNAME =';
  1142.      `unset environment' removes the variable from the environment,
  1143.      rather than assigning it an empty value.
  1144.  
  1145. 
  1146. File: gdb.info,  Node: Working Directory,  Next: Input/Output,  Prev: Environment,  Up: Running
  1147.  
  1148. Your Program's Working Directory
  1149. ================================
  1150.  
  1151.    Each time you start your program with `run', it inherits its
  1152. working directory from the current working directory of GDB.  GDB's
  1153. working directory is initially whatever it inherited from its parent
  1154. process (typically the shell), but you can specify a new working
  1155. directory in GDB with the `cd' command.
  1156.  
  1157.    The GDB working directory also serves as a default for the
  1158. commands that specify files for GDB to operate on.  *Note Files::.
  1159.  
  1160. `cd DIRECTORY'
  1161.      Set GDB's working directory to DIRECTORY.
  1162.  
  1163. `pwd'
  1164.      Print GDB's working directory.
  1165.  
  1166. 
  1167. File: gdb.info,  Node: Input/Output,  Next: Attach,  Prev: Working Directory,  Up: Running
  1168.  
  1169. Your Program's Input and Output
  1170. ===============================
  1171.  
  1172.    By default, the program you run under GDB does input and output to
  1173. the same terminal that GDB uses.  GDB switches the terminal to its
  1174. own terminal modes to interact with you, but it records the terminal
  1175. modes your program was using and switches back to them when you
  1176. continue running your program.
  1177.  
  1178. `info terminal'
  1179.      Displays GDB's recorded information about the terminal modes
  1180.      your program is using.
  1181.  
  1182.    You can redirect the program's input and/or output using shell
  1183. redirection with the `run' command.  For example,
  1184.  
  1185.      run > outfile
  1186.  
  1187. starts the program, diverting its output to the file `outfile'.
  1188.  
  1189.    Another way to specify where the program should do input and
  1190. output is with the `tty' command.  This command accepts a file name
  1191. as argument, and causes this file to be the default for future `run'
  1192. commands.  It also resets the controlling terminal for the child
  1193. process, for future `run' commands.  For example,
  1194.  
  1195.      tty /dev/ttyb
  1196.  
  1197. directs that processes started with subsequent `run' commands default
  1198. to do input and output on the terminal `/dev/ttyb' and have that as
  1199. their controlling terminal.
  1200.  
  1201.    An explicit redirection in `run' overrides the `tty' command's
  1202. effect on the input/output device, but not its effect on the
  1203. controlling terminal.
  1204.  
  1205.    When you use the `tty' command or redirect input in the `run'
  1206. command, only the input *for your program* is affected.  The input
  1207. for GDB still comes from your terminal.
  1208.  
  1209. 
  1210. File: gdb.info,  Node: Attach,  Next: Kill Process,  Prev: Input/Output,  Up: Running
  1211.  
  1212. Debugging an Already-Running Process
  1213. ====================================
  1214.  
  1215. `attach PROCESS-ID'
  1216.      This command attaches to a running process--one that was started
  1217.      outside GDB.  (`info files' will show your active targets.) 
  1218.      The command takes as argument a process ID.  The usual way to
  1219.      find out the process-id of a Unix process is with the `ps'
  1220.      utility, or with the `jobs -l' shell command.
  1221.  
  1222.      `attach' will not repeat if you press RET a second time after
  1223.      executing the command.
  1224.  
  1225.    To use `attach', you must be debugging in an environment which
  1226. supports processes.  You must also have permission to send the
  1227. process a signal, and it must have the same effective user ID as the
  1228. GDB process.
  1229.  
  1230.    When using `attach', you should first use the `file' command to
  1231. specify the program running in the process and load its symbol table.
  1232. *Note Files::.
  1233.  
  1234.    The first thing GDB does after arranging to debug the specified
  1235. process is to stop it.  You can examine and modify an attached
  1236. process with all the GDB commands that are ordinarily available when
  1237. you start processes with `run'.  You can insert breakpoints; you can
  1238. step and continue; you can modify storage.  If you would rather the
  1239. process continue running, you may use the `continue' command after
  1240. attaching GDB to the process.
  1241.  
  1242. `detach'
  1243.      When you have finished debugging the attached process, you can
  1244.      use the `detach' command to release it from GDB's control. 
  1245.      Detaching the process continues its execution.  After the
  1246.      `detach' command, that process and GDB become completely
  1247.      independent once more, and you are ready to `attach' another
  1248.      process or start one with `run'.  `detach' will not repeat if
  1249.      you press RET again after executing the command.
  1250.  
  1251.    If you exit GDB or use the `run' command while you have an
  1252. attached process, you kill that process.  By default, you will be
  1253. asked
  1254. for confirmation if you try to do either of these things; you can
  1255. control whether or not you need to confirm by using the `set
  1256. confirm' command (*note Messages/Warnings::.).
  1257.  
  1258. 
  1259. File: gdb.info,  Node: Kill Process,  Prev: Attach,  Up: Running
  1260.  
  1261. Killing the Child Process
  1262. =========================
  1263.  
  1264. `kill'
  1265.      Kill the child process in which your program is running under GDB.
  1266.  
  1267.    This command is useful if you wish to debug a core dump instead of
  1268. a
  1269. running process.  GDB ignores any core dump file while your program
  1270. is running.
  1271.  
  1272.    On some operating systems, a program can't be executed outside GDB
  1273. while
  1274. you have breakpoints set on it inside GDB.  You can use the `kill'
  1275. command in this situation to permit running the program outside the
  1276. debugger.
  1277.  
  1278.    The `kill' command is also useful if you wish to recompile and
  1279. relink the program, since on many systems it is impossible to modify
  1280. an executable file while it is running in a process.  In this case,
  1281. when you next type `run', GDB will notice that the file has changed,
  1282. and will re-read the symbol table (while trying to preserve your
  1283. current breakpoint settings).
  1284.  
  1285. 
  1286. File: gdb.info,  Node: Stopping,  Next: Stack,  Prev: Running,  Up: Top
  1287.  
  1288. Stopping and Continuing
  1289. ***********************
  1290.  
  1291.    The principal purpose of using a debugger is so that you can stop
  1292. your program before it terminates; or so that, if the program runs
  1293. into trouble, you can investigate and find out why.
  1294.  
  1295.    Inside GDB, your program may stop for any of several reasons, such
  1296. as a signal, a breakpoint, or reaching a new line after a GDB
  1297. command such as `step'.  You may then examine and change variables,
  1298. set
  1299. new breakpoints or remove old ones, and then continue execution. 
  1300. Usually, the messages shown by GDB provide ample explanation of the
  1301. status of your program--but you can also explicitly request this
  1302. information at any time.
  1303.  
  1304. `info program'
  1305.      Display information about the status of your program: whether it
  1306.      is running or not, what process it is, and why it stopped.
  1307.  
  1308. * Menu:
  1309.  
  1310. * Breakpoints::            Breakpoints, Watchpoints, and Exceptions
  1311. * Continuing and Stepping::    Resuming Execution
  1312. * Signals::            Signals
  1313.  
  1314. 
  1315. File: gdb.info,  Node: Breakpoints,  Next: Continuing and Stepping,  Prev: Stopping,  Up: Stopping
  1316.  
  1317. Breakpoints, Watchpoints, and Exceptions
  1318. ========================================
  1319.  
  1320.    A "breakpoint" makes your program stop whenever a certain point in
  1321. the program is reached.  For each breakpoint, you can add various
  1322. conditions to control in finer detail whether the program will stop.
  1323. You can set breakpoints with the `break' command and its variants
  1324. (*note Set Breaks::.), to specify the place where the program should
  1325. stop by line number, function name or exact address in the program. 
  1326. In languages with exception handling (such as GNU C++), you can also
  1327. set breakpoints  where an exception is raised (*note Exception
  1328. Handling::.).
  1329.  
  1330.    A "watchpoint" is a special breakpoint that stops your program
  1331. when the value of an expression changes.  You must use a different
  1332. command to set watchpoints (*note Set Watchpoints::.), but aside
  1333. from that, you can manage a watchpoint like any other breakpoint:
  1334. you enable, disable, and delete both breakpoints and watchpoints
  1335. using the same commands.
  1336.  
  1337.    Each breakpoint or watchpoint is assigned a number when it is
  1338. created; these numbers are successive integers starting with one. 
  1339. In many of the commands for controlling various features of
  1340. breakpoints you use the breakpoint number to say which breakpoint
  1341. you want to change.  Each breakpoint may be "enabled" or "disabled";
  1342. if
  1343. disabled, it has no effect on the program until you enable it again.
  1344.  
  1345. * Menu:
  1346.  
  1347. * Set Breaks::            Setting Breakpoints
  1348. * Set Watchpoints::        Setting Watchpoints
  1349. * Exception Handling::        Breakpoints and Exceptions
  1350. * Delete Breaks::        Deleting Breakpoints
  1351. * Disabling::            Disabling Breakpoints
  1352. * Conditions::            Break Conditions
  1353. * Break Commands::        Breakpoint Command Lists
  1354. * Breakpoint Menus::        Breakpoint Menus
  1355. * Error in Breakpoints::    
  1356.  
  1357.